{% extends "base.html" %}
{% load i18n %}
{% load static %}

{% block title %}{% trans "Search test runs" %}{% endblock %}

{% block contents %}
<div class="container-fluid container-cards-pf">
    <form class="form-horizontal" method="get">
        <div class="form-group">
            <label class="col-md-1 col-lg-1" for="id_summary">{% trans "Summary" %}</label>
            <div class="col-md-3 col-lg-3">
                <input id="id_summary" type="text" class="form-control" placeholder="{% trans 'Test run summary' %}">
            </div>

            <label class="col-md-1 col-lg-1" for="id_plan">{% trans "Plan ID" %}</label>
            <div class="col-md-3 col-lg-3">
                <input id="id_plan" type="text" class="form-control" placeholder="{% trans 'TestPlan ID' %}"
                    value="{{ form.plan.value|default:'' }}">
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-1 col-lg-1" for="id_product">{% trans "Product" %}</label>
            <div class="col-md-3 col-lg-3">
                <select class="form-control selectpicker" id="id_product">
                    <option value="">----------</option>
                {% for option in form.product.field.queryset %}
                    <option value="{{ option.pk }}" {% if form.product.value|add:'0' == option.pk %}selected{% endif %}>{{ option.name }}</option>
                {% endfor %}
                </select>
            </div>

            <label class="col-md-1 col-lg-1" for="id_version">{% trans "Version" %}</label>
            <div class="col-md-3 col-lg-3">
                <select class="form-control selectpicker" id="id_version">
                    <option value="">----------</option>
                {% for option in form.product_version.field.queryset %}
                    <option value="{{ option.pk }}" {% if form.product_version.value|add:'0' == option.pk %}selected{% endif %}>{{ option.value }}</option>
                {% endfor %}
                </select>
            </div>

            <label class="col-md-1 col-lg-1" for="id_build">{% trans "Build" %}</label>
            <div class="col-md-3 col-lg-3">
                <select class="form-control selectpicker" id="id_build">
                    <option value="">----------</option>
                {% for option in form.build.field.queryset %}
                    <option value="{{ option.pk }}" {% if form.build.value|add:'0' == option.pk %}selected{% endif %}>{{ option.name }}</option>
                {% endfor %}
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-1 col-lg-1" for="id_manager">{% trans "Manager" %}</label>
            <div class="col-md-3 col-lg-3">
                <input id="id_manager" type="text" class="form-control" placeholder="{% trans 'Username' %}">
            </div>

            <label class="col-md-1 col-lg-1" for="id_default_tester">{% trans "Default&nbsp;tester" %}</label>
            <div class="col-md-3 col-lg-3">
                <input id="id_default_tester" type="text" class="form-control" placeholder="{% trans 'Username' %}"
                        value="{{ form.default_tester.value|default:'' }}">
            </div>

            <label class="col-md-1 col-lg-1" for="id_running">{% trans "Running" %}</label>
            <div class="col-md-3 col-lg-3">
                <input class="bootstrap-switch" id="id_running" type="checkbox" checked>
            </div>
        </div>

        <div class="form-group">
            <label class="col-md-1 col-lg-1" for="id_tag">{% trans "Tag" %}</label>
            <div class="col-md-3 col-lg-3">
                <input id="id_tag" type="text" class="form-control" value="{{ form.tag__name__in.value|default:'' }}">
                <p class="help-block">{% trans "Separate multiple values with comma (,)" %}</p>
            </div>
        </div>


        <button id="btn_search" type="submit" class="btn btn-default btn-lg">{% trans "Search" %}</button>
    </form>

    <div class="panel panel-default" style="margin-top: 2em">
        <!-- Table HTML -->
        <table class="table table-striped table-bordered table-hover" id="resultsTable">
            <thead>
                <tr>
                    <th>{% trans "ID" %}</th>
                    <th>{% trans "Summary" %}</th>
                    <th>{% trans "Test plan" %}</th>
                    <th>{% trans "Manager" %}</th>
                    <th>{% trans "Default tester" %}</th>
                    <th>{% trans "Product" %}</th>
                    <th>{% trans "Version" %}</th>
                    <th>{% trans "Build" %}</th>
                    <th>{% trans "Finished at" %}</th>
                </tr>
            </thead>
        </table>

        {% include 'pagination.html' %}

    </div>
</div><!-- /container -->

<!-- JavaScript that is used in this page -->
<script src="{% static 'bootstrap-switch/dist/js/bootstrap-switch.min.js' %}"></script>
<script src="{% static 'bootstrap-select/dist/js/bootstrap-select.min.js' %}"></script>

<script src="{% static 'js/jsonrpc.js' %}"></script>
<script src="{% static 'js/utils.js' %}"></script>
<script src="{% static 'js/pagination.js' %}"></script>
<script src="{% static 'testruns/js/search.js' %}"></script>
{% endblock %}
